package cn.fuhe.controller.user;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.fuhe.bean.Car;
import cn.fuhe.bean.OrderUnion;
import cn.fuhe.bean.PagesEntity;
import cn.fuhe.bean.User;
import cn.fuhe.bean.UserAddress;
import cn.fuhe.controller.BaseServlet;
import cn.fuhe.dao.OrderDao;
import cn.fuhe.dao.OrderUnionDao;

@WebServlet("/order")
public class Order extends BaseServlet{
    @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
           this.doGet(req, resp);
        }

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		User user = (User)req.getSession().getAttribute("user");
		req.setAttribute("user", user);
		//int uid=user.getId();
	
		String curr = req.getParameter("page");
		String size = req.getParameter("size");
		
		int currpage = curr==null ? 1: Integer.parseInt(curr);
		int pagesize = size==null ? 5: Integer.parseInt(size);
		//OrderDao oDao = new OrderDao(); 
		OrderUnionDao ou = new OrderUnionDao();
		PagesEntity<OrderUnion>  orderList = ou.getUserAddressByPage(user.getId(), currpage, pagesize);
		HttpSession session = req.getSession(true);
		session.setAttribute("orderList", orderList);
		
		
	
		forward("personalcenter/Order1");
	
	}

}
